package com.zj.util;

import java.util.ArrayList;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class RegexUtil {
    public static String regex$="$\\{([^}])+\\}";
    public static String regex="#\\{([^}])+\\}";
    public static String sqlChar="?";


    public static String getSqlAndParamInSQL(String str,List<String> result){
        StringBuilder sb=new StringBuilder();
        char[] src=str.toCharArray();
        if (str==null||str.length()==0)return str;
        Pattern pattern = Pattern.compile(regex);
        Matcher matcher = pattern.matcher(str);
        int offset=0;
        while (matcher.find()) {
            String str2=matcher.group();
            int start=matcher.start();
            sb.append(src,offset,start-offset).append('?');
            offset=start+str2.length();
            result.add(str2.substring(2,str2.length()-1));
        }
        return sb.toString();
    }

}
